from org.eclipse.ui.part import ViewPart
from org.eclipse.swt import SWT
from org.eclipse.jface.viewers import TableViewer
from org.jyrcp.base import ViewCreator

class TableView(ViewCreator):
    def createPartControl(self, parent):
        myViewer = TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL)
        myViewer.contentProvider = ViewContentProvider()
        myViewer.labelProvider = ViewLabelProvider()
        
        return myViewer
        
from org.eclipse.jface.viewers import IStructuredContentProvider
from data.url_data import UrlData
    
class ViewContentProvider(IStructuredContentProvider):
    def __init__(self):
        """ n/a """
        
    def inputChanged(self, viewer, oldInput, newInput):
        """ n/a """

    def dispose(self):
        """ n/a """

    def getElements(self, inputElement):
        return [UrlData('Code', 'http://code.google.com'), 
                UrlData('Maps', 'http://maps.google.com'),
                UrlData('Mail', 'http://mail.google.com') ]

from org.eclipse.jface.viewers import LabelProvider, ITableLabelProvider
#from org.eclipse.ui import PlatformUI, ISharedImages

class ViewLabelProvider(LabelProvider, ITableLabelProvider):
    def getColumnText(self, obj, index):
        return self.getText(obj.title)


    def getColumnImage(self, obj, index):
        """ disabled because of RAP platform """
        #return self.getImage(obj)


    def getImage(self, obj):
        """ disabled because of RAP platform """
        #return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT)
        
